﻿@using PersonalFinances.Models
@model PersonalFinances.ViewModels.TransactionCreateViewModel

@{
    ViewBag.Title = "Create New Transaction";
}

<h2>@ViewBag.Title</h2>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Transaction</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Transaction.Description)
            @Html.ValidationMessageFor(model => model.Transaction.Description)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Date)
        </div>
        <div class="editor-field">
            @*@Html.TextBoxFor(model => model.Transaction.Date, new { @Value = (String.Format("{0:dd/MM/yyyy}", Model.Transaction.Date)) })*@
            @Html.EditorFor(model => model.Transaction.Date)
            @Html.ValidationMessageFor(model => model.Transaction.Date)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Value)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Transaction.Value)
            @Html.ValidationMessageFor(model => model.Transaction.Value)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Type)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Transaction.Type, new SelectList(Enum.GetValues(typeof(TransactionType))))
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Account)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Transaction.AccountID, new SelectList(Model.Accounts, "ID", "Name"))
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Category)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Transaction.CategoryID, new SelectList(Model.Categories, "ID", "Name"))
            @Html.ValidationMessageFor(model => model.Transaction.Category)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Paid)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Transaction.Paid)
            @Html.ValidationMessageFor(model => model.Transaction.Paid)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    <link href="/Content/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-ui-1.8.24.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#Transaction_Date").datepicker({ dateFormat: 'dd/mm/yy' });
        });
    </script>
}
